<template>
	<view class="mainpadding">
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 300rpx;" ></view>
		</view>
		<view class="mainpadding ffffff radius shangj" v-if="list.data.length" v-for="item in list.data" :key="item.id">
			<view class="flexbetween">
				<view class="bigtext fonweight xiaohei xiankuan">{{item.name}}</view>
				<view class="flexright xiankuan" v-if="item.yy_status == 3 ">
					<view class="xiaolan sanshier fonweight margin_right1">{{item.ccinfo.name}}</view>
					<view class="xiaolan sanshier fonweight"> 上架</view>
				</view>
			</view>
			<view class="margin_top2 flexbetween">
				<view class="shilitu">
					<image :src="item.image_text" mode=""></image>
				</view>
				<view class="" style="width: 66%;">
					<view class="xiaohui titletext nofonweight">库号：{{item.kh}}</view>
					<view class="xiaohui titletext nofonweight margin_top1" v-if="item.sp_time">
						上牌日期：{{item.sp_time_text}}</view>
					<view class="xiaohui titletext nofonweight margin_top1">买入价：
						<text class="xiaohong titletext fonweight">{{item.buy_price}}</text>
					</view>
					<view class="xiaohui titletext nofonweight margin_top1">卖出价：
						<text class="xiaohong titletext fonweight">{{item.price}}</text>
					</view>
					<view class="xiaohui titletext nofonweight margin_top1">服务费：
						<text class="xiaohong titletext fonweight">{{item.service_price}}</text>
					</view>
				</view>
			</view>
			<view class="flexright" v-if="item.yy_status == 1 ">
				<view class="xiaolanbtn margin_top2" @click="yuyue(item.id)">预约</view>
			</view>

		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")

	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			yuyue(id) {
				httpRequest.modal('提示', '确定预约当前商品？', true, (res) => {
					if (res) {
						httpRequest.request("/api/cccl/zpGoodsYyapply", 'GET', {
							goods_id: id
						}, false, false, true).then(res => {
							if (res.code == 1) {
								httpRequest.toast(res.msg)
								this.init()
							}else if(res.code == -1){
								httpRequest.toast("为先绑定收款设置模块内容再进行预约！")
								return false
							}else{
								httpRequest.toast(res.msg)
							}
						})
					}
				})

			},
			init(isPage, page) { //提现记录
				let _this = this
				let url = "/api/cccl/myZpGoods"
				let data = {
					page: page || 1,
					limit: _this.limit
				}
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
							this.pageShow = true
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.xiaolanbtn {
		width: 140rpx;
		height: 60rpx;
		color: #fff;
		background-color: #3478f5;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 30rpx;
		font-size: 32rpx;
	}

	.shilitu {
		width: 190rpx;
		height: 180rpx;
		border-radius: 20rpx;

		image {
			border-radius: 20rpx;
			width: 100%;
			height: 100%;
		}
	}

	.shangj {
		margin-top: 30rpx;
	}

	.shangj:first-child {
		margin-top: 0rpx;
	}
</style>